<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <link href="/layui/css/modules/layer/default/layer.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/css/index.css"/>
</head>
<body class="main-body-admin">
<nav style="margin-top: 10px;">
    <button class="layui-btn" onclick="edit()">审核</button>
    <input class="layui-input-inline" id="searchValue"/>
    <button class="layui-btn layui-btn-normal" onclick="search()">搜索</button>
</nav>
<table id="team" lay-filter="test"></table>
<script src="/js/jquery.min.js"></script>
<script src="/js/config/server.js"></script>
<script src="/js/common/login.js"></script>
<script src="/js/common/upload.js"></script>
<script src="/layui/layui.all.js"></script>
<script>
  var table;
  var loadIndex = layer.load(2);
  handlerGet('/common/ping', 'teacher', function () {
    layui.use('table', function () {
      table = layui.table;
      table.render({
        elem: '#team'
        , height: 515
        , url: host + '/rest/topic/listValidate' //数据接口
        , page: true //开启分页
        , limit: 15
        , limits : [15, 30, 45]
        , cols: [[ //表头
          {checkbox: true}
          , {field: 'topicId', title: 'ID', width: 60, sort: true}
          , {field: 'name', title: '课题名', width: 140}
          , {field: 'publishYear', title: '届数', width: 100, sort: true}
        ]]
      });
      layer.close(loadIndex);
    });
  }, function (data) {
    layer.msg('请检查网络并重试'+data.responseText)
  });

  function reloadAll() {
    layui.use('table', function () {
      var table = layui.table;
      table.reload('team', {
        url: host + '/rest/topic/listValidate'
      });
    })
  }


  function edit() {
    var checkStatus = table.checkStatus('team');
    if(checkStatus.data.length !== 1){
      layer.msg('请选择一条记录')
    }else {
      // layer.prompt({
      //   formType: 2,
      //   value: '输入备注',
      //   title: '提交审核',
      //   area: ['400px', '150px'] //自定义文本域宽高
      // }, function (value, index, elem) {
      //   var data = {
      //     comment: value
      //   };
      //
      //   handlerPost('/bus/teacher/submitCheck/' + id + '/' + teacherId, 'teacher',JSON.stringify(data), function (data) {
      //       if (data.code === '0') {
      //         layer.msg('提交审核成功，等待负责人回复')
      //       }
      //       if (data.code === '416') {
      //         layer.msg('请勿重复提交审核')
      //       }
      //     }, function (data) {
      //       layer.msg('提交失败，请检查网络并重试')
      //     }
      //   )
      //   ;
      //   layer.close(index);
      // });
      sessionStorage.setItem('validateTopicId', checkStatus.data[0].topicId);
      frameTip("审核课题", 'validate/validate.html')
    }
  }

  function frameTip(title, url) {
    layer.open({
      title: title
      , type: 2
      , content: url
      , btnAlign: 'c'
      , resize: true
      , tipsMore: true
      , area: ['270px', '300px']
      ,cancel: function () {
        sessionStorage.removeItem('validateTopicId');
        sessionStorage.removeItem('editCollege');
        sessionStorage.removeItem('editMajor');
        sessionStorage.removeItem('editJudge');
        reloadAll();
      }
    });
  }
  function tips(content, title, confirm) {
    return layer.open({
      title: title
      , type: 1
      , content: content
      , btnAlign: 'c'
      , resize: true
      , tipsMore: true
      , area: ['300px', '200px']
      , btn: ['确认', '取消']
      , yes: function (index, layero) {
        confirm();
      },
      cancel: function () {
      }
    });
  }
  function search() {
    var value = $("#searchValue").val();
    if (value === '' || value === ' ') {
      layer.msg('请输入查询参数');
      return;
    }
    layui.use('table', function () {
      var table = layui.table;
      table.reload('team', {
        url: host+'/rest/topic/search?name=' + value+''
        , where: {}
      });
    })
  }

</script>
<script id="editData" type="text/html">
    <div id="Tips">
        <label for="name">团队名</label>
        <input name="name" type="text" id="name" value="name##VA" required/> <br/>
        <label for="year">毕业届数</label>
        <select name="year" id="year">
            <option selected>2018</option>
            <option>2017</option>
            <option>2016</option>
            <option>2015</option>
        </select>
        <br/>
        <label for="majorId">专业</label>
        <select id="majorId" name="majorId"></select>
    </div>
</script>
<script id="loadFromExcel" type="text/html">
    <div>
        <input type="file" id="selectFile" />
        <progress id="progressBar" value="0" max="100"></progress>
        <span id="percentage"></span>
    </div>
</script>
</body>
</html>